<!doctype html>
<html class="no-js" lang="en" xmlns:th="http://www.thymeleaf.org">

<head th:replace="common4 :: common_header(~{::title},~{},~{})">
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>哈尔滨机务段车辆检修维护管理</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">

</head>

<body style="background: url(../images/b1.webp) no-repeat center fixed !important;background-size: 100% 100%">
<!--[if lt IE 8]>
    <p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<div class="error-pagewrap">
    <div class="error-page-int">
        <div class="text-center m-b-md custom-login">
            <h3 style="color:#fff;">哈尔滨机务段车辆检修维护管理</h3>
            <!-- <p>This is the best app ever!</p>  -->
        </div>
        <div class="content-error">
            <div class="hpanel">
                <div class="panel-body">
                    <form id="loginForm">
                        <div class="form-group">
                            <label class="control-label" for="username">用户名</label>
                            <input type="text" placeholder="请输入用户名" title="Please enter you username"
                                   name="username" id="uname" class="form-control">
                            <span class="help-block small"></span>
                        </div>
                        <div class="form-group">
                            <label class="control-label" for="password">密码</label>
                            <input type="password" title="Please enter your password" placeholder="请输入密码"
                                   required="" value="" name="password" id="pword" class="form-control">
                            <span class="help-block small"></span>
                        </div>
                        <div class="checkbox login-checkbox" style="height: 30px;" id="tip">
                            <!--     <label>
                                         <input type="checkbox" class="i-checks"> Remember me </label>
                                 <p class="help-block small">(if this is a private computer)</p>  -->
                        </div>
                        <button class="btn btn-success btn-block loginbtn" type="button" onclick="login()">登录</button>
                        <!--         <a class="btn btn-default btn-block" href="#">Register</a> -->
                    </form>
                </div>
            </div>
        </div>
        <div class="text-center login-footer">
        </div>
    </div>
</div>

<script type="text/javascript" th:inline="none">
    var $ = jQuery;
    $(function () {
        $(".uname").focus(function () {
            $("#tip").empty();
        });
        $(".pword").focus(function () {
            $("#tip").empty();
        });
        // 刷新验证码

    })

    function formReset() {
        $('#loginForm')[0].reset();
    }


    function login() {


        var temp = getFormJson("loginForm");
        temp.role = 1;
        if (temp.username == "") {
            $("#tip").html("<font color='red'>* 请输入用户名！</font>");
            return;
        }
        if (temp.password == "") {
            $("#tip").html("<font color='red'>* 请输入密码！</font>");
            return;
        }

        $.post("/TLogin/login", temp, function (data) {
            if (data.isFlag == 0) {
                window.location.href = "/TLogin/main";
                sessionStorage.setItem("userid", data.user.id)
                sessionStorage.setItem("userName", data.user.name)
                sessionStorage.setItem("userjobid", data.user.jobId)
            } else if (data.isFlag == 1) {
                $("#tip").html("<font color='red'>*密码输入不正确！</font>");
            } else if (data.isFlag == 2) {
                $("#tip").html("<font color='red'>*用户名输入不正确！</font>");
            }


        });
    }

</script>
</body>

</html>